package com.zmn.plat.services.impl.channel.bail;

import com.zmn.plat.model.entity.channel.bail.ChannelBailLog;
import com.zmn.plat.model.entity.channel.bail.ChannelBailLogQuery;
import com.zmn.plat.persistence.interfaces.channel.bail.ChannelBailLogDAO;
import com.zmn.plat.services.interfaces.channel.bail.ChannelBailLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;



/**
 * 描述: 渠道保证金操作日志接口实现类
 *
 * @author jiafei
 * @since  2021-06Channel51:40
 */
@Slf4j
@Service
public class BailLogServiceImpl implements ChannelBailLogService {

    private static final String TAG = "渠道保证金操作日志基础服务接口";

    @Resource
    private ChannelBailLogDAO channelBailLogDAO;

    @Override
    public ChannelBailLog findById(Integer id) {

        if (Objects.isNull(id)) {
            log.error("[{}],根据id查询数据id为null", TAG);
            return null;
        }
        return channelBailLogDAO.findById(id);
    }

    @Override
    public List<ChannelBailLog> listPageByQuery(ChannelBailLogQuery query) {

        if (Objects.isNull(query)) {
            log.error("[{}],按条件查询数据,query为null", TAG);
            return null;
        }
        query.setTotalCount(channelBailLogDAO.countByQuery(query));
        return channelBailLogDAO.listPageByQuery(query);
    }

    @Override
    public List<ChannelBailLog> listByQuery(ChannelBailLogQuery query) {

        if (Objects.isNull(query)) {
            log.error("[{}],按条件查询数据,query为null", TAG);
            return null;
        }
        return channelBailLogDAO.listByQuery(query);
    }

    @Override
    public List<ChannelBailLog> listByChannelId(Integer channelId) {

        if (Objects.isNull(channelId)) {
            log.error("[{}],根据channelId查询数据channelId为null", TAG);
            return null;
        }
        return channelBailLogDAO.listByChannelId(channelId);
    }

    @Override
    public Integer countByQuery(ChannelBailLogQuery query) {

        if (Objects.isNull(query)) {
            log.error("[{}],按条件统计数据,query为null", TAG);
            return null;
        }
        return channelBailLogDAO.countByQuery(query);
    }

    @Override
    public Integer updateByKey(ChannelBailLog bailLog) {

        if (Objects.isNull(bailLog.getId())){
            log.error("[{}],根据id修改数据,bailLog为null", TAG);
            return null;
        }
        return channelBailLogDAO.updateByKey(bailLog);
    }

    @Override
    public Integer insert (ChannelBailLog bailLog){

        if (Objects.isNull(bailLog)){
            log.error("[{}],新增数据,bailLog为null", TAG);
            return null;
        }
        return channelBailLogDAO.insert(bailLog);
    }

    @Override
    public Integer deleteByKey(Integer id) {

        if (Objects.isNull(id)){
            log.error("[{}],根据id删除数据,id为null", TAG);
            return null;
        }
        return channelBailLogDAO.deleteByKey(id);
    }

}